package com.bonc.ioc.demo.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * 2020/11/9
 */
public class DateTimeUtil {

    /**
     * Date to stamp
     */
    public static Long dateToStamp(String date, String pattern) {
        Calendar calendar = Calendar.getInstance();
        long time_Stamp = 0L;

        try {
            calendar.setTime((new SimpleDateFormat(pattern)).parse(date));
            time_Stamp = calendar.getTimeInMillis();
        } catch (ParseException var6) {
            var6.printStackTrace();
        }

        return time_Stamp;
    }

    /**
     * Stamp to Date
     */
    public static String stampToDate(long time_Stamp, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(time_Stamp);
    }

}
